#ifndef PLAYLIST_H
#define PLAYLIST_H

#include <QAbstractListModel>
#include <QList>
#include "Track.h"

class Playlist : public QAbstractListModel {
    Q_OBJECT
public:
    enum RoleNames {
        TitleRole = Qt::UserRole + 1,
        ArtistRole,
        PathRole,
        DurationRole
    };

    explicit Playlist(QObject* parent = nullptr);
    int rowCount(const QModelIndex& parent = QModelIndex()) const override;
    QVariant data(const QModelIndex& index, int role) const override;
    QHash<int, QByteArray> roleNames() const override;

    void appendTrack(Track *track);
    void removeTrack(int row);
    Track* at(int row) const;
    Track* fromPath(const QString& path) const;
    Track* fromPath(const QUrl& path) const;
    void clear();
    bool isEmpty() const;

private:
    QList<Track*> _tracks;
};

#endif // PLAYLIST_H
